<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>TODO supply a title</title>
        <style type="text/css">
            .selected {
                background: #f00;
                color:#fff;
            }
            #imgElement {
                width: 183px;
                
            }
            #content span {
                cursor: pointer;
            }
            
            #titleName {
                position: relative;
                top: 40px;
                border: 1px solid #999;
                background: #a43;
                opacity: 0.7;
                color:#fff;
            }
        </style>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script type="text/javascript" src="jquery/jquery-1.8.3.js"></script>
        <script type="text/javascript">
            $(function(){
            
               //比较不好的方式
                var index = 0;
                
                
                
                $("#imgElement img").each(function(n) {
                            $("#content").append("<span>"+(n+1)+"</span>&nbsp;");
                        }).css("display","none")
                        .filter(":eq("+(index++)+")").show();
                //鼠标点击 
                $("#content span").click(function(){
                   var ele = $(this).html();
                   index = (--ele);
                   change();
                });
                
                $("#content span:eq(0)").addClass("selected");
                function change() {
                    var img = $("#imgElement img").css("display","none")
                            .filter(":eq("+(index)+")")
                            .fadeIn("slow")
                            ;
                    //
                    $("#titleName").html(img.attr("alt"));
                    $("#content span").removeClass().filter(":eq( "+index+")").addClass("selected");
                    index++;
                    if(index>=$("#imgElement img").size()) {
                        index = 0;
                    }
                }
                setInterval(change, 3000);
            });
        </script>
    </head>
    <body>
        <div id="content"></div>
        <div id="imgElement">
            <div id="titleName">文章标题</div>
            <img src="img/images1.jpg" alt="hebe1"/>
            <img src="img/images2.jpg" alt="hebe2"/>
            <img src="img/images3.jpg" alt="hebe3"/>
            <img src="img/images4.jpg" alt="hebe4"/>
            <img src="img/images5.jpg" alt="hebe5"/>
        </div>
    </body>
</html>
